# Makefile for system utilities (For Gnu Make)

# Where to install them: BIN for object library, HDR for headers
BIN = $$.Lib
HDR = $$.CLib

# Objects to create
BASE =	O.Alloca O.Bag O.Bitset O.Chdir O.Coroutines O.Deque O.Dir	\
	O.Dirscan O.Efopen O.Emalloc O.Fcrypt O.Filelen O.Filetime	\
	O.Filetype O.Filter O.Frename O.Getwd O.Isatty O.Map O.Message	\
	O.Mktemp O.Oscmd O.Panic O.Popen O.Queue O.Random O.Ring 	\
	O.Set O.Stack O.Stat O.Strcchr O.Strdup O.Strlcmp O.Strlower	\
	O.Strndup O.Strnlcmp O.Strnpcpy O.Strnucmp O.Strpcpy		\
	O.Strucmp O.Strupper O.Swi O.Time O.Touch O.Unexec

OTHER =	O.Getopt O.Getopt1 O.Regex O.Caller O.ProgLimit	O.Vars \
	O.ProfileAsm O.ProfileC O.ProfileT

OBJS = $(BASE) $(OTHER)

# Assembler command for source in directory S.
O.%: S.%
	$(ASM) $(ASMFLAGS) -from $< -to $@ -stamp -quit

.PHONY: all install clean clobber

all: Utils

install: Utils
	Copy H.* $(HDR).H.* FQ~C~V
	Copy Sys.H.* $(HDR).Sys.H.* FQ~C~V
	Copy Getopt.H.Getopt $(HDR).H.Getopt FQ~C~V
	Copy Regex.H.Regex $(HDR).H.Regex FQ~C~V
	Copy Profile.H.Profile $(HDR).H.Profile FQ~C~V
	Copy Utils $(BIN).Utils FQ~C~V

clean:
	Wipe O.* F~C~V

clobber: clean
	Remove Utils

Utils: $(OBJS)
	Remove Utils
	Libfile -c -o Utils O.*

# Profiler, Regex and Getopt libraries live in subdirectories

O.Getopt: Getopt.C.Getopt
	$(CC) $(CFLAGS) -c Getopt.C.Getopt

O.Getopt1: Getopt.C.Getopt1
	$(CC) $(CFLAGS) -c Getopt.C.Getopt1

O.Regex: Regex.C.Regex
	$(CC) $(CFLAGS) -c Regex.C.Regex

O.ProfileC: Profile.C.ProfileC
	$(CC) $(CFLAGS) -c Profile.C.ProfileC

O.ProfileT: Profile.C.ProfileT
	$(CC) $(CFLAGS) -c Profile.C.ProfileT

O.ProfileAsm: Profile.S.ProfileAsm
	$(ASM) $(ASMFLAGS) -from Profile.S.ProfileAsm -to O.ProfileAsm -stamp -quit
